package com.example.demo.mapper;

import com.example.demo.model.entity.PrizeRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PrizeRecordMapper {

    @Select("select count(*) from prize_record where user_id = #{userId} and activity_id = #{activityId}")
    int getUserCount(int userId, int activityId);

    @Insert("insert into prize_record (activity_id, prize_level, user_id, is_hit) values (#{activityId}, #{prizeLevel}, #{userId}, #{isHit})")
    void insert(PrizeRecord prizeRecord);

    @Select("select * from prize_record where activity_id = #{activityId}")
    List<PrizeRecord> selectByActivityId(int activityId);
}
